<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<style type="text/css">
   pre.idl { border:solid thin; background:#eee; color:#000; padding:0.5em }
</style>
<script type="text/javascript">
    function submitForm()
    { 
        var xhr; 
        try {  xhr = new ActiveXObject('Msxml2.XMLHTTP');   }
        catch (e) 
        {
            try {   xhr = new ActiveXObject('Microsoft.XMLHTTP');    }
            catch (e2) 
            {
              try {  xhr = new XMLHttpRequest();     }
              catch (e3) {  xhr = false;   }
            }
         }
      
        xhr.onreadystatechange  = function()
        { 
             if(xhr.readyState  == 4)
             {
                  if(xhr.status  == 200) {
                      response = xhr.responseText;
                      response = format_xml(response);
                      response = response.replace(/>/gi, ">\n");

                      document.getElementById('res').innerText = document.getElementById('res').textContent = response;
                  }
                  else  {
                     document.res.text = "Received:"  + xhr.responseText;
                 }
             }
        }; 
    
       xhr.open("OPTIONS", "/xcmis/rest/cmisatom",  true); 
       xhr.send(null); 
    } 
 
     function spaces(len)
     {
     	var s = '';
     	var indent = len*4;
     	for (i=0;i<indent;i++) {s += " ";}
     	
     	return s;
     }
     
     function format_xml(str)
     {
     	var xml = '';
     
     	// add newlines
     	str = str.replace(/(>)(<)(\/*)/g,"$1\r$2$3");
     
     	// add indents
     	var pad = 0;
     	var indent;
     	var node;
     
     	// split the string
     	var strArr = str.split("\r");
     
     
     	// check the various tag states
     	for (var i = 0; i < strArr.length; i++) {
     		indent = 0;
     		node = strArr[i];
     
     		if(node.match(/.+<\/\w[^>]*>$/)){ //open and closing in the same line
     			indent = 0;
     		} else if(node.match(/^<\/\w/)){ // closing tag
     			if (pad > 0){pad -= 1;}
     		} else if (node.match(/^<\w[^>]*[^\/]>.*$/)){ //opening tag
     			indent = 1;
     		} else
     			indent = 0;
     		//}
     
     		xml += spaces(pad) + node + "\r";
     		pad += indent;
     	}
     
     	return xml;
     }


</script>

    <title>xCMIS WADL</title>
</head>
<body onLoad="submitForm();">
            <p>xCMIS WADL:</p>
           <pre id="res" class="idl">
           </pre>

</body>
</html>
